<?php use_helper('I18N', 'Date') ?>

<?php use_stylesheet('/sf/sf_admin/css/main') ?>

<div id="sf_admin_container">

<h1><?php echo __('Send Newsletters') ?></h1>
<?php echo form_tag('newsletter/create')?>
<div id="sf_admin_header">
<?php if ($sf_request->getError('delete')): ?>
<div class="form-errors">
  <h2><?php echo __('Could not delete the selected %name%', array('%name%' => 'News')) ?></h2>
  <ul>
    <li><?php echo $sf_request->getError('delete') ?></li>
  </ul>
</div>
<?php endif; ?>
</div>


<div id="sf_admin_content">
<?php if (!$pager->getNbResults()): ?>
<?php echo __('no result') ?>
<?php else: ?>


<table cellspacing="0" class="sf_admin_list">
<thead>
<tr>
<th id="sf_admin_list_th_select">
        <?php echo __('Select') ?>
</th>
<th id="sf_admin_list_th_name">
        <?php echo __('Name') ?>
</th>
<th id="sf_admin_list_th_updated_at">
      <?php echo __('Updated at')?>
</th>
  <th id="sf_admin_list_th_sf_actions"><?php echo __('Actions') ?></th>
</tr>
</thead>
<tfoot>
<tr><th colspan="4">
<div class="float-right">
<?php if ($pager->haveToPaginate()): ?>
  <?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/images/first.png', array('align' => 'absmiddle', 'alt' => __('First'), 'title' => __('First'))), 'news/list?page=1') ?>
  <?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/images/previous.png', array('align' => 'absmiddle', 'alt' => __('Previous'), 'title' => __('Previous'))), 'news/list?page='.$pager->getPreviousPage()) ?>

  <?php foreach ($pager->getLinks() as $page): ?>
    <?php echo link_to_unless($page == $pager->getPage(), $page, 'news/list?page='.$page) ?>
  <?php endforeach; ?>

  <?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/images/next.png', array('align' => 'absmiddle', 'alt' => __('Next'), 'title' => __('Next'))), 'news/list?page='.$pager->getNextPage()) ?>
  <?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/images/last.png', array('align' => 'absmiddle', 'alt' => __('Last'), 'title' => __('Last'))), 'news/list?page='.$pager->getLastPage()) ?>
<?php endif; ?>
</div>
<?php echo format_number_choice('[0] no result|[1] 1 result|(1,+Inf] %1% results', array('%1%' => $pager->getNbResults()), $pager->getNbResults()) ?>
</th></tr>
</tfoot>
<tbody>
<?php $i = 1; foreach ($pager->getResults() as $news): $odd = fmod(++$i, 2) ?>
<tr class="sf_admin_row_<?php echo $odd ?>">
<td>
    <input type="checkbox" id="send_id[]" name="send_id[]" value="<?php echo $news->getId() ?>" />
</td>
      <td><?php echo $news->getName() ?></td>
    <td><?php echo ($news->getUpdatedAt() !== null && $news->getUpdatedAt() !== '') ? format_date($news->getUpdatedAt(), "f") : '' ?></td>

<td>
<ul class="sf_admin_td_actions">
  <li><?php echo link_to(image_tag('/sf/sf_admin/images/send_icon.png', array('alt' => __('send'), 'title' => __('send'))), 'news/submit?id='.$news->getId()) ?></li>
</ul>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

<?php endif; ?>

<ul class="sf_admin_actions">
  <li><?php echo submit_tag(__('Send')
                            , array ('class' => 'sf_admin_action_create')) ?></li>
  </form>
</ul>
</div>
</div>